﻿using System;

namespace Jerkymon.Cryptography
{
    public class MD5
    {
		#region Static Methods (1)
		public static string Hash(string InputStr)
        {
            try
            {
                System.Security.Cryptography.MD5CryptoServiceProvider MD5Hasher = new System.Security.Cryptography.MD5CryptoServiceProvider();
                byte[] rawBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(InputStr);
                byte[] myHash = MD5Hasher.ComputeHash(rawBytes);
                int myCapacity = (myHash.Length * 2 + (myHash.Length / 8));
                System.Text.StringBuilder sb = new System.Text.StringBuilder(myCapacity);
                for (int I = 0; I <= myHash.Length - 1; I++)
                {
                    sb.Append(BitConverter.ToString(myHash, I, 1));
                }
                return sb.ToString().TrimEnd(new char[] { ' ' });
            }
            catch
            {
                return "0";
            }
 
          
            //FormAuthentication.
        }
		#endregion
    }
}
